home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_09_06 / 9n06018b < prev    next >
Text File  |  1991-02-16  |  511b  |  34 lines

  1.  
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. main()
  6. {
  7.     int rows = 0;
  8.     long **pl;
  9.     int i;
  10.  
  11.     while (rows < 1) {
  12.         printf("Enter number of 10 element rows: ");
  13.         scanf("%4d", &rows);
  14.     }
  15.  
  16.     pl = malloc(rows * sizeof(long *));
  17.     if (pl == NULL) {
  18.         printf("malloc of pl failed\n");
  19.         exit(1);
  20.     }
  21.  
  22.     for (i = 0; i < rows; ++i) {
  23.         pl[i] = malloc(10 * sizeof(long));
  24.         if (pl[i] == NULL) {
  25.             printf("malloc of pl[%d] failed\n", i);
  26.             exit(1);
  27.         }
  28.     }
  29.  
  30.     pl[0][2] = 1234;
  31.     pl[0][9] = 9876;
  32. }
  33.  
  34.